package com.zijie.hosptal.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.hosptal.common.Result;
import com.zijie.hosptal.pojo.po.Log;
import com.zijie.hosptal.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log")
public class LogController {

    private LogService logService;

    @Autowired
    public void setLogService(LogService logService) {
        this.logService = logService;
    }


    @GetMapping("/getAllLog")
    public Result<?> getAllLog(Integer page, Integer limit, Log log) {
        Page<Log> page1 = Page.of(page, limit);
        page1 = logService.list(page1, log);
        return Result.success(page1);
    }
    //单个删除
    @DeleteMapping("/{id}")
    public Result<?> deleteLog(@PathVariable Integer id) {
        boolean flag = logService.removeById(id);
        return flag ? Result.success() : Result.fail("删除失败");
    }
}
